#!/usr/bin/env python
# -*- encoding: utf-8 -*-
from typing import Optional
import uuid
from sqlalchemy.orm import Session
from models.event_image import event_image_model

class CRUDEventImg:
    def create_event_image(self, db: Session, img_id, img_path) -> Optional[event_image_model]:
        new_event_img =  event_image_model(img_id, img_path)
        db.add(new_event_img)
        db.commit()
        db.refresh(new_event_img)
        return new_event_img
    #def create_event(self, db: Session, event_id: str) -> Optional[event_image_model]:
    #    return db.query(event_image_model).filter(event_id == event_id).first()

    def set_event_id(self, db: Session, img_id, event_id ) :
        db.query(event_image_model).filter_by(event_image_id = img_id).update({'event_id':event_id})
        db.commit()
       # db.refresh()

    
           
event_img = CRUDEventImg()
